package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.BusinessReportDataVO;
import com.itheima.pojo.MemberReportVO;
import com.itheima.pojo.SetmealReportVO;
import com.itheima.sevice.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 获取会员统计数据
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        MemberReportVO memberReport = reportService.getMemberReport();

        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS, memberReport);
    }

    /**
     * 套餐预约占比饼图
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){
        SetmealReportVO setmealReportVO = reportService.getSetmealReport();

        return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS, setmealReportVO);
    }

    /**
     * 运营数据统计
     * @return
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
        BusinessReportDataVO businessReportDataVO = reportService.getBusinessReportData();

        return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS, businessReportDataVO);
    }

    /**
     * 导出数据到Excel
     */
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response) throws Exception {
        reportService.exportBusinessReport(response);
    }
}
